﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ControlQA.ascx.cs" Inherits="Usercontrol_ControlQA" %>
  
<link rel="stylesheet" href='<%=ResolveUrl("~/Css/FormLayout.css")%>' type="text/css" />
<link rel="stylesheet" href='<%=ResolveUrl("~/cleditor/jquery.cleditor.css")%>' type="text/css" />
<script src='<%=ResolveUrl("~/Scripts/jquery.cleditor.js")%>' type="text/javascript"></script>



<script type="text/javascript">
    var $j = jQuery.noConflict();
    function pageLoad() {
        var options = {
            width: 400,
            height: 200,
            controls: "bold italic underline strikethrough subscript superscript | font size " +
                    "style | color highlight removeformat | bullets numbering | outdent " +
                    "indent | alignleft center alignright justify | undo redo | " +
                    "rule link image unlink | cut copy paste pastetext | print source"
        };

        var editor = $j("#editor").cleditor(options)[0];

        $j("#btnClear").click(function (e) {
            e.preventDefault();
            editor.focus();
            editor.clear();
        });

        $j("#btnAddImage").click(function () {
            editor.execCommand("insertimage", "http://images.free-extras.com/pics/s/smile-1620.JPG", null, null)
            editor.focus();
        });

        $j("#btnGetHtml").click(function () {
            alert($j("#editor").val());
        });

        // Add the service method call as an onclick handler for the a tag
        $j("#<%=btSend.ClientID %>").click(function () {
        if ($j("#<%=txtCapCha.ClientID %>").val()==<%= Session["CaptchaImageText"].ToString() %>)
        {
            $j.ajax({
                type: "POST",
                url: "../../Webservice/WebService.asmx/SendMail",
                data: "{'email':'" + $j("#<%=txtMail.ClientID %>").val() + "','name':'" + $j("#<%=txtName.ClientID %>").val() + "','body':'" + $j("#editor").val() + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",               success: function(message) {
                  //Hide the contact form and show the message letting the user know the email has been sent
                  
                   alert("Cám ơn bạn đã gửi câu hỏi,chúng tôi sẽ trả lời bạn sớm nhất");
                },
                error: function(errormessage) {
                //you would not show the real error to the user - this is just to see if everything is working
                    
               
                    alert(errormessage.responseText);
                   
                }
            });
            }
            else
            {
                     alert("Mã xác nhận không đúng");
            }
        });

    }
</script>


<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
    
     <div class="form">
            <h1>Giải đáp thắc mắc của bạn</h1>

                      <fieldset>
                        <legend accesskey="B"><span style="text-decoration: underline;">G</span>ửi câu hỏi</legend>
                        <label for="billingName">Họ tên:</label>
                          <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                        <br/>
                        <label for="billingAddress">Mail:</label>
                         <asp:TextBox ID="txtMail" runat="server"></asp:TextBox>
                        
                         <br />
                         <div style="width: 300px">
                            <div>
                               
                                <textarea id="editor" rows="0" cols="0"></textarea>
                            </div>
                        </div>
                         <br/>
                         <label for="billingAddress">Mã xác nhận</label>
                         <img src='<%=ResolveUrl("JpegImage.aspx")%>' /><br>
                        <br/>
                         <br/>
                         <label for="billingAddress">Mã xác nhận:</label>
                         <asp:TextBox ID="txtCapCha" runat="server"></asp:TextBox>
                        <br/>
                      </fieldset>
        <div id="buttons">
      <asp:Button ID="btSend" runat="server" Text="Gửi" />
        </div>
  </div>

   


</ContentTemplate>
</asp:UpdatePanel>



